/*
 * test_rapidjson.cpp
 *
 *  Created on: Jul 12, 2014
 *      Author: killerg
 */





#include "share/rapidjson/document.h"
#include "share/rapidjson/reader.h"
#include "share/rapidjson/writer.h"
#include "share/rapidjson/stringbuffer.h"

using namespace rapidjson;

bool test_rapidjson() {
	Document doc;
	Document::AllocatorType &al = doc.GetAllocator();
	doc.SetObject();
	doc.AddMember("hello", "world", al);

	Value val;
	val.SetObject();
	val.AddMember("hi", "hi", al);
	doc.AddMember("h1", val, al);

	val.SetArray();
	val.PushBack(1, al);
	val.PushBack("hello", al);
	doc.AddMember("h2", val, al);

	GenericStringBuffer<UTF8<>, Document::AllocatorType> sb(&al);
	Writer<GenericStringBuffer<UTF8<>, Document::AllocatorType>, UTF8<>, UTF8<>, Document::AllocatorType > sbwr(sb, &al);
	doc.Accept(sbwr);
	printf("%s\n", sb.GetString());

	return true;
}
